package org.example.config;

import org.example.interceptors.LoginProtectedInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * Web MVC配置类
 * 用于配置Spring MVC的相关设置，如拦截器等
 */
@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Autowired
    private LoginProtectedInterceptor loginProtectedInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册登录保护拦截器，并应用到 /headline/** 路径下所有请求
        registry.addInterceptor(loginProtectedInterceptor).addPathPatterns("/headline/**");
    }
}